package 力扣91;

/**
 * @ClassName : Day10_160_相交链表
 * @Author : 骆发茂
 * @Date: 2021/12/22 20:33
 * @Description :https://leetcode-cn.com/problems/intersection-of-two-linked-lists/
 *这里要注意是节点相同，地址和值都要相同。
 * https://leetcode-cn.com/problems/intersection-of-two-linked-lists/solution/gei-zi-ji-liu-ge-bi-ji-by-kkbill/
 */
public class Day10_160_相交链表_双指针 {

    public class Solution {
        public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            ListNode pA = headA, pB = headB;
            while (pA != pB) {
                pA = pA == null ? headB : pA.next;
                pB = pB == null ? headB : pB.next;
            }
            return pA;
        }
    }

}